// 代理 仅在DEV时有效，在服务器部署后失效

/**
 * <a href='https://github.com/chimurai/http-proxy-middleware'>http-proxy-middleware</a>
 */
declare type ProxyType = {
  [key: string]: {
    [key: string]: {
      target?: string;
      changeOrigin?: boolean;
      pathRewrite?: { [key: string]: any };
      logLevel?: any;
      // eslint-disable-next-line @typescript-eslint/ban-types
      onProxyReq?: Function;
      // eslint-disable-next-line @typescript-eslint/ban-types
      onError?: Function;
      // http-proxy-middleware option
      forward?: string;
      agent?: any;
      ssl?: any;
      ws?: boolean;
      xfwd?: boolean;
      secure?: boolean;
      toProxy?: boolean;
      prependPath?: boolean;
      ignorePath?: boolean;
      localAddress?: any;
      preserveHeaderKeyCase?: boolean;
      auth?: any;
      hostRewrite?: any;
      autoRewrite?: any;
      protocolRewrite?: any;
      cookieDomainRewrite?: { [key: string]: any };
      cookiePathRewrite?: { [key: string]: any };
      headers?: any;
      proxyTimeout?: number;
      timeout?: number;
      followRedirects?: boolean;
      selfHandleResponse?: boolean;
      buffer?: any;
    }
  }
}

const proxy: ProxyType = {
  dev: {
    '/api': {
      target: 'http://localhost:60914/star',
      changeOrigin: true,
      pathRewrite: { '^/api': '' },
      logLevel: 'debug',
    },
  },
};

export default proxy;